home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-01
/
msoftapp.zip
/
VIEWER.CPP
< prev
next >
Wrap
C/C++ Source or Header
|
1993-06-01
|
4KB
|
148 lines
// viewer.cpp : Defines the class behaviors for the MDI sample application.
#include"viewer.h"
COLORREF clrTextArray[5] = // used by HELLO.CPP and BOUNCE.CPP
{
RGB(0, 0, 0),
RGB(255, 0, 0),
RGB(0, 255, 0),
RGB( 0, 0, 255),
RGB(255, 255, 255)
};
// Create one global CTheApp object to create and start the application
CTheApp theApp;
// CMainWindow message map:
BEGIN_MESSAGE_MAP(CMainWindow, CMDIFrameWnd)
ON_WM_CREATE()
ON_COMMAND(IDM_ABOUT, OnAbout)
ON_COMMAND(IDM_HELLO, OnNewHello)
ON_COMMAND(IDM_BOUNCE, OnNewBounce)
ON_COMMAND(IDM_FILEWIN, OnNewFileWin)
ON_COMMAND(IDM_CASCADE, MDICascade)
ON_COMMAND(IDM_TILE, MDITile)
ON_COMMAND(IDM_NEXT, MDINext)
ON_COMMAND(IDM_ARRANGE, MDIIconArrange)
ON_COMMAND(IDM_EXIT, OnExit)
ON_COMMAND(IDM_BUTTON_TEST, OnButtonTestDlg)
ON_MESSAGE(WM_CHILDDESTROY, OnChildDestroy)
END_MESSAGE_MAP()
CMainWindow::CMainWindow(void)
{
VERIFY(LoadAccelTable("ViewerAccel"));
Create(NULL, "MDI Viewer", WS_OVERLAPPEDWINDOW, rectDefault,
NULL, "Init");
}
// OnCreate: Load app's initial MDI frame menu and create an MDI client
int CMainWindow::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
m_pMenuInit = new CMenu();
m_pMenuInit->LoadMenu("Init");
CreateClient(lpCreateStruct, m_pMenuInit->GetSubMenu(0));
return 0;
}
// OnAbout: Display app's about box (defined in about.dlg).
void CMainWindow::OnAbout(void)
{
CDialog about("AboutBox", this);
about.DoModal();
}
// OnNewHello: Create a new Hello child window.
void CMainWindow::OnNewHello(void)
{
CHelloWin *pHelloWnd = new CHelloWin;
if(!pHelloWnd->Create("Hello",
(WS_CHILD | WS_VISIBLE | WS_OVERLAPPEDWINDOW),
rectDefault, this))
{
delete pHelloWnd; // HWND not created
return;
}
pHelloWnd->ShowWindow(SW_SHOW);
// the default PostNcDestroy handler will delete this object when destroyed
}
// OnNewBounce: Create a new Bounce child window.
void CMainWindow::OnNewBounce(void)
{
CBounceWin *pBounceWnd = new CBounceWin;
if(!pBounceWnd->Create("Bounce",
(WS_CHILD | WS_VISIBLE | WS_OVERLAPPEDWINDOW),
rectDefault, this))
{
delete pBounceWnd; // HWND not created
return;
}
pBounceWnd->ShowWindow(SW_SHOW);
// the default PostNcDestroy handler will delete this object when destroyed
}
// OnNewFileWin:
void CMainWindow::OnNewFileWin(void)
{
CFileWin *pCFileWin = new CFileWin;
if(pCFileWin->Open())
{
if(!pCFileWin->Create(NULL,"FileWin"))
{
delete pCFileWin;
return;
}
else
pCFileWin->ShowWindow(SW_SHOW);
}
}
// OnChildDestroy:
// This handler is triggered when a CBounceWin, CFileWnd or CHelloWin
// destroys itself -- the default implementation here does nothing but could
// be customized to do additional work.
//
LONG CMainWindow::OnChildDestroy(UINT /*hWnd*/, LONG /* lParam */)
{
return 0;
}
// Destructor: Destroy all existing child windows.
CMainWindow::~CMainWindow(void)
{
delete m_pMenuInit;
}
// OnExit: Exit the application.
void CMainWindow::OnExit(void)
{
DestroyWindow();
}
void CMainWindow::OnButtonTestDlg()
{
CButtonTestDlg dlg;
dlg.DoModal();
}
// InitInstance:
// Create and display the application main frame window
//
BOOL CTheApp::InitInstance(void)
{
SetDialogBkColor();
m_pMainWnd = new CMainWindow();
m_pMainWnd->ShowWindow(m_nCmdShow);
m_pMainWnd->UpdateWindow();
return TRUE;
}